#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll T,n,m,L,V,s[100009],tt[100009];
struct node
{
    ll d,v,a;
}c[100009];
ll ss(ll y,ll j,ll t)
{
    if(j!=0)
    return (V*V-y*y)/j/2+t;
    else
    return (y>V)?y:0;
}
bool cs(ll x)
{
    bool cs1=false;
    for(ll i=1;i<=m;i++)
    {
        //cout<<s[i]-c[x].d<<" "<<V<<endl;
        if(ss(c[x].v,c[x].a,s[i]-c[x].d))
        {
            tt[i]++;
            cs1=true;
        }
    }
    return cs1;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    for(ll t=1;t<=T;t++)
    {
        ll ans=0;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(ll i=1;i<=n;i++)
        scanf("%lld%lld%lld",&c[i].d,&c[i].v,&c[i].a);
        for(ll i=1;i<=m;i++)
        scanf("%lld",&s[i]);
        for(ll i=1;i<=m;i++)
        tt[i]=0;
        for(ll i=1;i<=n;i++)
        if(cs(i)==1)
        {
            ans++;
        }

        cout<<ans<<endl;
    }
}

//(y*t+0.5*j*t*t)*2*j=x*x-y*y